
<div class="pageContent">
	<div class="pageFormContent">
		<dl>
			<dt>查找目标：</dt>
			<dd>
				<input name="fromString" class='textInput required' maxlength="20" value='' />
			</dd>
		</dl>
		<dl class="nowrap">
			<dt>替换为：</dt>
			<dd>
				<input name="toString"  class="textInput"/>
			</dd>
		</dl>
		<dl class="nowrap">
			<dt>&nbsp;</dt>
			<dd>
				<label><input type="checkbox" name="ignoreCase"  checked="true">忽略大小写</label>
			</dd>
		</dl>
		<div class="formBar">
			<ul>
				<li><div class="buttonActive">
						<div class="buttonContent">
							<button type="button" name="btnReplace">替换</button>
						</div>
					</div></li>
				<li>
					<div class="buttonActiveGrey">
						<div class="buttonContent">
							<button type="button" name="btnClose" class="close">取消</button>
						</div>
					</div>
				</li>
			</ul>
		</div>
	</div>
</div>
<script>
(function($){
	var page = DWZ.context();
	//给替换按钮绑定点击事件
	$("button[name='btnReplace']",page).on("click",function(){
		var fromString = $("input[name='fromString']",page).val();
		var toString = $("input[name='toString']",page).val();
		var ignoreCase = $("input[name='ignoreCase']").is(':checked');
		
		if(!fromString){
			alertMsg.error('请输入查找目标。');
			return false;
		}
		
		var panel = navTab.getPanel('enumCodeTranslate');
		var reg=new RegExp(fromString,ignoreCase?"ig":"g");
		var replaceCount = 0;
		$.each($("div[name='translatePanel'] table input[type='text']",panel),function(i,e){
			var value = $(e).val();
			if(reg.test(value)){
				$(e).val(value.replace(reg,toString));
				$(e).addClass("focus");
				replaceCount ++;
			}else{
				$(e).removeClass();
			}
		});
		
		alertMsg.info('共替换'+replaceCount+'处信息');
		$.pdialog.closeCurrent();
	});
	
	
})(jQuery)
</script>